aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bif_binary.c
AgeCommit message (Collapse)Author
2018-08-16Do not allocate good and bad shifts for single byte lookupsJosé Valim
The single byte lookups always rely on `memchr` and never really use the good and bad shifts arrays.
2018-08-16Merge branch 'josevalim/jv-sb/PR-1803/OTP-15238' into masterLukas Larsson
Optimize binary match from 10% up to 70x
2018-08-07Optimize binary matchJosé Valim
The idea is to use memchr on the first lookup for binary:match/2 and also after every match on binary:matches/2. We only use memchr in case of matches because benchmarks showed that using memchr even when we had false positives could negatively affect performance. This speeds up binary matching and binary splitting by 4x in some cases and by 70x in other scenarios (when the last character in the needle does not occur in the subject). The reason to use memchr is that it is highly specialized in most modern operating systems, often defaulting to SIMD operations. The implementation uses the reduction count to figure out how many bytes should be read with memchr. We could increase those numbers but they do not seem to make a large difference.
2018-06-18Update copyright yearHenrik Nord
2018-03-09Always use sys_memcpy/cmp/etc instead of plain memcpy/cmp/etcJohn Högberg
2018-02-26Replace binary:bin_to_list CIF implementation with binary_to_listJohn Högberg
binary:bin_to_list had a poor implementation that resulted in excessive garbage collection. binary_to_list is almost identical and has a generally better implementation, so I've replaced binary:bin_to_list's CIF with a thin wrapper around binary_to_list. Granted, binary_to_list has a deprecated indexing scheme, but we're unlikely to ever remote it entirely and it's somewhat easy to move it to the 'binary' module later on.
2018-01-16Merge branch 'sverker/build-proc-bin'Sverker Eriksson
2018-01-05erts: Refactor more usage of erts_build_proc_binSverker Eriksson
2017-09-13Merge branch 'potatosalad/erts/binary_find_bif_improved/PR-1480/OTP-14610'Lukas Larsson
* potatosalad/erts/binary_find_bif_improved/PR-1480/OTP-14610: stdlib: Improved BIF for binary matches and split.
2017-09-07Replace ad-hoc MIN/MAX macros with common onesJohn Högberg
Besides being noisy, they were already defined by a global Unix- specific header, causing the Windows build to fail if one forgot to define them.
2017-09-06stdlib: Improved BIF for binary matches and split.Andrew Bennett
2017-05-04Update copyright yearRaimo Niskanen
2017-04-11erts: Init refc=1 in erts_bin_nrml_allocSverker Eriksson
Only term_to_binary needed some extra attention as it used to initialize refc as 0 instead of 1.
2017-02-15Merge branch 'fix-source-typos'Björn Gustavsson
* fix-source-typos: (25 commits) Fixed typos in system/doc Fixed typos in lib/xmerl Fixed typos in lib/wx Fixed typos in lib/stdlib Fixed typos in lib/snmp Fixed typos in lib/ssl Fixed typos in lib/ssh Fixed typos in PKCS-8.asn1 file Fixed typos in lib/parsetools Fixed typos in lib/orber Fixed typos in lib/mnesia Fixed typos in lib/megaco Fixed typos in lib/kernel Fixed typos in lib/jinterface Fixed typos in lib/inets Fixed typos in lib/hipe Fixed typos in lib/eunit Fixed typos in lib/erl_interface Fixed typos in lib/eldap Fixed typos in lib/edoc ...
2017-02-14erts: Add deallocation veto for magic destructorsSverker Eriksson
A magic destructor can return 0 and thereby take control and prolong the lifetime of a magic binary.
2017-02-14Fixed typos in ertsAndrew Dryga
2017-02-06Use magic refs for binary compile patternsRickard Green
2016-03-15update copyright-yearHenrik Nord
2015-11-13stdlib: Fix bug in binary:split for empty binarySverker Eriksson
Bug introduced om master branch at b93e9b611056828a and reported in ERL-43.
2015-11-04Merge branch 'sverk/binary_split_bif'Sverker Eriksson
OTP-13082 * sverk/binary_split_bif: erts: Minor refactor for binary find BIF backend erts: Refactor BIF for binary:match,matches,split erts: Refactor backend of binary:split erts: Replace 0 with THE_NON_VALUE stdlib: Add BIF option 'trim_all' to binary:split/3 stdlib: Add BIF binary:split/2 and binary:split/3 Conflicts: bootstrap/lib/stdlib/ebin/binary.beam
2015-11-04erts: Minor refactor for binary find BIF backendAndrew Bennett
* Use NULL instead of THE_NON_VALUE for non-Eterm variable. * Add BinaryFindState_bignum struct to avoid unnecessary type casting.
2015-11-04erts: Refactor BIF for binary:match,matches,splitAndrew Bennett
with an common do_binary_find() used by match, matches and split.
2015-11-04erts: Refactor backend of binary:splitSverker Eriksson
to reduce code volume.
2015-11-04erts: Replace 0 with THE_NON_VALUESverker Eriksson
2015-11-04stdlib: Add BIF option 'trim_all' to binary:split/3Andrew Bennett
2015-11-04stdlib: Add BIF binary:split/2 and binary:split/3Andrew Bennett
2015-06-24erts: Remove HALFWORD_HEAP definitionBjörn-Egil Dahlberg
2015-06-18Change license text to APLv2Bruce Yinhe
2015-03-20Merge branch 'rickard/time_api/OTP-11997'Rickard Green
* rickard/time_api/OTP-11997: (22 commits) Update primary bootstrap inets: Suppress deprecated warning on erlang:now/0 inets: Cleanup of multiple copies of functions Add inets_lib with common functions used by multiple modules inets: Update comments Suppress deprecated warning on erlang:now/0 Use new time API and be back-compatible in inets Remove unused functions and removed redundant test asn1 test SUITE: Eliminate use of now/0 Disable deprecated warning on erlang:now/0 in diameter_lib Use new time API and be back-compatible in ssh Replace all calls to now/0 in CT with new time API functions test_server: Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API otp_SUITE: Warn for calls to erlang:now/0 Replace usage of erlang:now() with usage of new API Multiple timer wheels Erlang based BIF timer implementation for scalability Implement ethread events with timeout ... Conflicts: bootstrap/bin/start.boot bootstrap/bin/start_clean.boot bootstrap/lib/compiler/ebin/beam_asm.beam bootstrap/lib/compiler/ebin/compile.beam bootstrap/lib/kernel/ebin/auth.beam bootstrap/lib/kernel/ebin/dist_util.beam bootstrap/lib/kernel/ebin/global.beam bootstrap/lib/kernel/ebin/hipe_unified_loader.beam bootstrap/lib/kernel/ebin/inet_db.beam bootstrap/lib/kernel/ebin/inet_dns.beam bootstrap/lib/kernel/ebin/inet_res.beam bootstrap/lib/kernel/ebin/os.beam bootstrap/lib/kernel/ebin/pg2.beam bootstrap/lib/stdlib/ebin/dets.beam bootstrap/lib/stdlib/ebin/dets_utils.beam bootstrap/lib/stdlib/ebin/erl_tar.beam bootstrap/lib/stdlib/ebin/escript.beam bootstrap/lib/stdlib/ebin/file_sorter.beam bootstrap/lib/stdlib/ebin/otp_internal.beam bootstrap/lib/stdlib/ebin/qlc.beam bootstrap/lib/stdlib/ebin/random.beam bootstrap/lib/stdlib/ebin/supervisor.beam bootstrap/lib/stdlib/ebin/timer.beam erts/aclocal.m4 erts/emulator/beam/bif.c erts/emulator/beam/erl_bif_info.c erts/emulator/beam/erl_db_hash.c erts/emulator/beam/erl_init.c erts/emulator/beam/erl_process.h erts/emulator/beam/erl_thr_progress.c erts/emulator/beam/utils.c erts/emulator/sys/unix/sys.c erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/init.beam erts/preloaded/src/erts_internal.erl lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl lib/diameter/src/base/diameter_lib.erl lib/kernel/src/os.erl lib/ssh/test/ssh_basic_SUITE.erl system/doc/efficiency_guide/advanced.xml
2015-03-20Introduce a new time APIRickard Green
The old time API is based on erlang:now/0. The major issue with erlang:now/0 is that it was intended to be used for so many unrelated things. This tied these unrelated operations together and unnecessarily caused performance, scalability as well as accuracy, and precision issues for operations that do not need to have such issues. The new API spreads different functionality over multiple functions in order to improve on this. The new API consists of a number of new BIFs: - erlang:convert_time_unit/3 - erlang:monotonic_time/0 - erlang:monotonic_time/1 - erlang:system_time/0 - erlang:system_time/1 - erlang:time_offset/0 - erlang:time_offset/1 - erlang:timestamp/0 - erlang:unique_integer/0 - erlang:unique_integer/1 - os:system_time/0 - os:system_time/1 and a number of extensions of existing BIFs: - erlang:monitor(time_offset, clock_service) - erlang:system_flag(time_offset, finalize) - erlang:system_info(os_monotonic_time_source) - erlang:system_info(time_offset) - erlang:system_info(time_warp_mode) - erlang:system_info(time_correction) - erlang:system_info(start_time) See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
2014-10-24Merge branch 'sverk/hipe-inline-reserve-trap-frame'Sverker Eriksson
* sverk/hipe-inline-reserve-trap-frame: erts: Extend usage of ASM macro to avoid including asm macros in C code erts: Make hipe_{un}reserve_beam_trap_frame INLINE
2014-10-24erts: Make hipe_{un}reserve_beam_trap_frame INLINESverker Eriksson
2014-09-04erts: Refactor binary allocation interface to also initialize BinarySverker Eriksson
except the reference counter 'refc', as different callers have different strategies regarding the lifetime of the binary.
2014-08-08erts: Fix neg int overflow when sint is min sizeLukas Larsson
When INT64_MIN is the value of a Sint64 we have to first cast it to an Uint64 before negating it. Otherwise we get an integer overflow which is undefined behaviour and in gcc 4.9 this results in -0 instead of -9223372036854775808 in gcc 4.8.
2014-05-22Make binary BIFs converting from lists yield on large inputRickard Green
- erlang:list_to_binary/1 - erlang:iolist_to_binary/1 - erlang:list_to_bitstring/1 - binary:list_to_bin/1
2013-09-20Check all pattern arguments passed to binary:matches/2Mike Sassak
Including an empty binary as one of multiple patterns passed to binary:matches/2 would crash BEAM with: "Cannot reallocate 1342177280 bytes of memory (of type "tmp")". This ensures each pattern is valid before trying to match.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2012-02-21erts: Refactor new helper function erts_init_trap_exportSverker Eriksson
2011-12-09Update copyright yearsBjörn-Egil Dahlberg
2011-11-16Remove GCC 4.6 set-but-not-used warning from erl_bif_binaryPatrik Nyblom
2011-11-16Make binary:match with scope return correct valuesPatrik Nyblom
2011-10-26Use the proper macros in all BIFsBjörn Gustavsson
As a preparation for changing the calling convention for BIFs, make sure that all BIFs use the macros. Also, eliminate all calls from one BIF to another, since that also breaks the calling convention abstraction.
2010-11-29Teach binary:matches not to return 'nomatch' on empty inputPatrik Nyblom
2010-09-07Teach erl_bif_binary not leak memory by doing malloc(0)Patrik Nyblom
2010-08-30Merge branch 'pan/ets_binary_overhead/OTP-8762' into devPatrik Nyblom
* pan/ets_binary_overhead/OTP-8762: Remove binary overhead counter from ets objects
2010-08-19Remove binary overhead counter from ets objectsPatrik Nyblom
As the overhead counter got larger and never really was needed in ets objects, I removed them. A few stray comments of XXX:PaN type from halfword dev removed in the process.
2010-08-12Increase vheap counter to Uint64Björn-Egil Dahlberg
This will reduce the risk of integer wrapping in bin vheap counting. The vheap size series will now use the golden ratio instead of doubling and fibonacci sequences. OTP #8730
2010-07-20One off-heap list, to eliminate two words per ETS object.Sverker Eriksson
Merging the three off-heap lists (binaries, funs and externals) into one list. This reduces memory consumption by two words (pointers) per ETS object.
2010-05-21Correct typos in EEP-0031 implementationTuncer Ayaz
Signed-off-by: Tuncer Ayaz <[email protected]>
2010-05-20Merge branch 'pan/otp_8217_binary' into devErlang/OTP
* pan/otp_8217_binary: Add documentation for binary module Add more tests and make some go easier on small systems Correct Boyer More and trapping for longest_common_suffix Add longer timetrap to testcases and add binary to app file Add guard BIFs binary_part/2,3 Add binary:{encode,decode}_unsigned({1,2} Add referenced_byte_size/1 Add binary:list_to_bin/1 and binary:copy/1,2 Add bin_to_list/{1,2,3} Add binary:longest_common_prefix/longest_common_suffix Add binary:part to erl_bif_binary.c Move binary module bif's to erl_bif_binary.c Count reductions for process even when not trapping Add random compare testcase Teach BIF's binary:match/matches interrupting/restarting Teach binary.c the semantics to take longest instead of shortest match Initial commit of the binary EEP OTP-8217 Implement EEP31 The module binary from EEP31 (and EEP9) is implemented.