From fdf830df3136549c66659f8a275d9a94c4c636cd Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 9 Nov 2026 14:12:31 +0000 Subject: [PATCH] Give PHP's start-up engine profile and the matched User-Agent default The performance options page, the cloud to on-premise guide and the IP Intelligence algorithm page now say that the engine PHP builds when it starts, from the php.ini file, always uses MaxPerformance, and why. The IP Intelligence page also says that an engine PHP code builds later from a settings array defaults to Balanced. The match metadata section now says that UserAgents is filled in only when Update Matched User Agent is on, which it is by default. --- src/devicedetection/cloudtoonpremise.md | 2 ++ src/devicedetection/features/falsepositivecontrol.md | 4 ++-- src/devicedetection/features/performanceoptions.md | 2 ++ src/ipintelligence/algorithm.md | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/devicedetection/cloudtoonpremise.md b/src/devicedetection/cloudtoonpremise.md index b7a851d6ed..ac27369bd1 100644 --- a/src/devicedetection/cloudtoonpremise.md +++ b/src/devicedetection/cloudtoonpremise.md @@ -166,6 +166,8 @@ Download new data files from the [51Degrees Distributor](@ref Services_Distribut - **LowMemory** - Slowest but minimal memory usage - **Balanced** - Default middle ground +In PHP, the engine built when PHP starts always uses `MaxPerformance`, so there is no profile to choose. See [Performance options](@ref DeviceDetection_Features_PerformanceOptions) for the reason. + **Deployment Options** - **In-Process** - Fastest option, detection in your application diff --git a/src/devicedetection/features/falsepositivecontrol.md b/src/devicedetection/features/falsepositivecontrol.md index 339befe873..01126f37f8 100644 --- a/src/devicedetection/features/falsepositivecontrol.md +++ b/src/devicedetection/features/falsepositivecontrol.md @@ -40,10 +40,10 @@ By default, `Difference` and `Drift` are set to 0 (i.e., no deviation from the e # Match metadata -Regardless of the settings used, the result will return additional metadata that can be queried to find out details about the match. +Whatever the `Difference` and `Drift` settings, the result will return additional metadata that can be queried to find out details about the match. `Difference` - Contains the difference value between the supplied evidence and the returned match. -`UserAgents` - Contains a list of the matching substrings from the User-Agent. +`UserAgents` - Contains a list of the matching substrings from the User-Agent. The list is filled in only when the Update Matched User Agent setting is on, which it is by default. `Drift` - Contains the drift value between the supplied evidence and the returned match. `MatchedNodes` - The number of 'nodes' in the @hash tree where a match was found. If this is zero then no match was found. `Method` - The method used to find a match. 'EXACT' indicates an exact match. 'NONE' indicates no match. Any other value is the name of the technique used to find the result that best matches the supplied evidence. diff --git a/src/devicedetection/features/performanceoptions.md b/src/devicedetection/features/performanceoptions.md index 122f01fafc..922d5f7b7e 100644 --- a/src/devicedetection/features/performanceoptions.md +++ b/src/devicedetection/features/performanceoptions.md @@ -26,6 +26,8 @@ The table below explains the options, from fastest performance and highest memor |Balanced (Default)|Some collections are loaded into memory at startup and the rest are read through caches of a fixed size. Frequently used items stay in memory, so disk reads are relatively uncommon for a typical web server workload.|Use for general workloads without extreme memory or performance requirements.| |LowMemory|Data always streamed from disk on-demand. | Recommended when the lowest possible memory usage is more important than performance. | +The default is `Balanced`, except for the engine PHP builds when it starts. That engine is built from the php.ini file and always uses `MaxPerformance`, and any other profile set in the php.ini file is refused. PHP usually serves requests from worker processes copied from the process that built the engine. With a profile that reads from the data file, those workers would share one open data file and its read position, and corrupt each other's reads. + The precise values associated with each template can be seen in the source code on [GitHub](https://github.com/51Degrees/51degrees-cxx/blob/67503df045efb32e84eb59fe7e320772dd6475db/src/hash/hash.c#L177). We measured throughput, startup time, and memory for Device Detection on seven machines, with the data file held in memory and with `Balanced`. The results are in the [hardware benchmarks](@ref ProductSummaries_Benchmarks_Hardware). diff --git a/src/ipintelligence/algorithm.md b/src/ipintelligence/algorithm.md index 70caaf5d12..6dc0931116 100644 --- a/src/ipintelligence/algorithm.md +++ b/src/ipintelligence/algorithm.md @@ -32,4 +32,6 @@ The algorithm is implemented in C for use in applications including edge computi - **Simple** - high-level language APIs make deployment simple for developers of all experience levels. - **Automatic Update** - data can be updated automatically without requiring a process restart. +`Balanced` is the default profile, except for the engine PHP builds when it starts. That engine is built from the php.ini file and always holds all the data in memory with `MaxPerformance`, because PHP usually serves requests from worker processes copied from the process that built the engine, and with a profile that reads from the data file those workers would corrupt each other's reads. An engine that PHP code builds later, from a settings array, may use any profile and defaults to `Balanced`. + See the [C code](https://github.com/51Degrees/51degrees-cxx/tree/main/src/ipi/graph) to find out more about the implementation.