pnoltes opened a new pull request, #692: URL: https://github.com/apache/celix/pull/692
# Intro This PR updates the Apache Celix filter to utilize typed properties entries and also refactors the filter implementation. My intention was to create a small PR allowing filters to work with typed properties before starting on array support. However, I observed several issues with the filter implementation that I also wanted to address. # Benchmark With this PR, a filter match will take into account the underlying properties entry type and use it for a more efficient comparison. A Filter match benchmark is introduced (and run before using the typed properties entries in filter match) to ensure the desired effect. Here are some before and after results (measured on my machine), where the range indicates the size of the properties set used within a filter match. ## Before Refactor ``` -------------------------------------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------------------------------------------------------------- FilterBenchmark_testStringCFilter/10000/process_time/real_time 14.5 ns 14.5 ns 48853882 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=68.9608M/s FilterBenchmark_testStringFilter/10000/process_time/real_time 14.4 ns 14.4 ns 48922109 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=69.5677M/s FilterBenchmark_testLongFilter/10000/process_time/real_time 22.3 ns 22.3 ns 31418137 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=44.8544M/s FilterBenchmark_testBoolFilter/10000/process_time/real_time 16.3 ns 16.3 ns 42884878 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=61.21M/s FilterBenchmark_testVersionFilter/10000/process_time/real_time 131 ns 131 ns 5332730 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=7.6231M/s FilterBenchmark_testVersionWithQualifierFilter/10000/process_time/real_time 163 ns 163 ns 4351054 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=6.13215M/s FilterBenchmark_testStringGreaterEqualFilter/10000/process_time/real_time 14.4 ns 14.4 ns 48966825 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=69.4911M/s FilterBenchmark_testLongGreaterEqualFilter/10000/process_time/real_time 22.1 ns 22.1 ns 29620437 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=45.307M/s FilterBenchmark_testDoubleGreaterEqualFilter/10000/process_time/real_time 43.5 ns 43.5 ns 16141792 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=22.968M/s FilterBenchmark_versionGreaterEqualFilter/10000/process_time/real_time 129 ns 129 ns 5429183 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=7.74544M/s FilterBenchmark_versionRangeFilter/10000/process_time/real_time 276 ns 276 ns 2534677 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=3.61734M/s FilterBenchmark_substringFilter/10000/process_time/real_time 276 ns 276 ns 2534366 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=3.61947M/s FilterBenchmark_complexFilter/10000/process_time/real_time 28.1 ns 28.1 ns 25516281 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=35.631M/s ``` ## After refactor ``` -------------------------------------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------------------------------------------------------------- FilterBenchmark_testStringCFilter/10000/process_time/real_time 15.4 ns 15.4 ns 45535697 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=64.9322M/s FilterBenchmark_testStringFilter/10000/process_time/real_time 15.4 ns 15.4 ns 45357990 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=64.7906M/s FilterBenchmark_testLongFilter/10000/process_time/real_time 14.9 ns 14.9 ns 46921381 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=66.9823M/s FilterBenchmark_testBoolFilter/10000/process_time/real_time 15.4 ns 15.4 ns 45496705 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=64.8934M/s FilterBenchmark_testVersionFilter/10000/process_time/real_time 19.1 ns 19.1 ns 36715526 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=52.4212M/s FilterBenchmark_testVersionWithQualifierFilter/10000/process_time/real_time 19.6 ns 19.6 ns 35566450 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=50.8923M/s FilterBenchmark_testStringGreaterEqualFilter/10000/process_time/real_time 14.8 ns 14.8 ns 47205823 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=67.484M/s FilterBenchmark_testLongGreaterEqualFilter/10000/process_time/real_time 15.7 ns 15.7 ns 44793529 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=63.8461M/s FilterBenchmark_testDoubleGreaterEqualFilter/10000/process_time/real_time 16.7 ns 16.7 ns 42395112 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=60.0551M/s FilterBenchmark_versionGreaterEqualFilter/10000/process_time/real_time 25.6 ns 25.6 ns 27321443 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=39.0526M/s FilterBenchmark_versionRangeFilter/10000/process_time/real_time 40.9 ns 40.9 ns 17123791 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=24.4385M/s FilterBenchmark_substringFilter/10000/process_time/real_time 40.8 ns 40.8 ns 17131224 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=24.5143M/s FilterBenchmark_complexFilter/10000/process_time/real_time 29.3 ns 29.3 ns 23892366 fillEntriesOptimizationBufferPercentage=1 fillStringOptimizationBufferPercentage=0.992188 items_per_second=34.1668M/s ``` # Substring Refactor The filter substring implementation was incorrect (not according to the [RFC](https://datatracker.ietf.org/doc/html/rfc4515)) and has been updated. Additionally, the previous implementation required a malloc during matching; this need has now been removed, ensuring that a filter match does not require additional memory and thus cannot fail due to an allocation error. # Small Refactor of AND and OR The matching for AND and OR operators has been updated so that `(|)` and `(&)` will return true. # Service Registration Service registration, including component service registration, has been updated. Now, `service.id` and `service.version` are stored as `long` and `celix_version_t` types, respectively. Also, some minor "last boy scout rule" changes have been implemented for error handling in the service registration flow. # Error Handling Most of the string parsing part has been refactored to use `open_memstream`. Error handling, including error injection testing, is now in place. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org