def get_windows_features()

in mozetl/graphics/graphics_telemetry_dashboard.py [0:0]


def get_windows_features():
    windows_compositor_map = windows_features.map(
        lambda p: (get_compositor(p),)
    ).countByKey()
    d3d11_status_map = windows_features.map(
        lambda p: (get_d3d11_status(p),)
    ).countByKey()
    d2d_status_map = windows_features.map(get_d2d_status).countByKey()

    def get_content_backends(rdd):
        rdd = rdd.filter(lambda p: p[GfxKey].get("ContentBackend") is not None)
        rdd = rdd.map(lambda p: (p[GfxKey]["ContentBackend"],))
        return rdd.countByKey()

    content_backends = get_content_backends(windows_features)

    warp_pings = windows_features.filter(lambda p: get_d3d11_status(p) == "warp")
    warp_pings = repartition(warp_pings)
    warp_status_map = warp_pings.map(lambda p: (get_warp_status(p),)).countByKey()

    texture_sharing_map = (
        windows_features.filter(has_working_d3d11)
        .map(get_texture_sharing_status)
        .countByKey()
    )

    blacklisted_pings = windows_features.filter(
        lambda p: get_d3d11_status(p) == "blacklisted"
    )
    blacklisted_pings = repartition(blacklisted_pings)
    blacklisted_devices = map_x_to_count(blacklisted_pings, "deviceID")
    blacklisted_drivers = map_x_to_count(blacklisted_pings, "driverVersion")
    blacklisted_os = map_x_to_count(blacklisted_pings, "OSVersion")

    blocked_pings = windows_features.filter(lambda p: get_d3d11_status(p) == "blocked")
    blocked_pings = repartition(blocked_pings)
    blocked_vendors = map_x_to_count(blocked_pings, "vendorID")

    # Media decoder backends.
    def get_media_decoders(rdd):
        rdd = rdd.filter(lambda p: p.get(MediaDecoderKey, None) is not None)
        if rdd.count() == 0:
            # These three values correspond to WMF Software, DXVA D3D11, and DXVA D3D9
            return [0, 0, 0]
        decoders = rdd.map(lambda p: p.get(MediaDecoderKey)).reduce(lambda x, y: x + y)
        return [int(i) for i in decoders]

    media_decoders = get_media_decoders(windows_features)

    def gpu_process_map(rdd):
        return rdd.map(lambda p: (gpu_process_status(p),)).countByKey()

    def advanced_layers_map(rdd):
        return rdd.map(lambda p: (advanced_layers_status(p),)).countByKey()

    # Now, build the same data except per version.
    feature_pings_by_os = map_x_to_count(windows_features, "OSVersion")
    windows_features_by_version = {}
    for os_version in feature_pings_by_os:
        if os_version not in important_windows_versions:
            continue
        subset = windows_features.filter(lambda p: p["OSVersion"] == os_version)
        subset = repartition(subset)

        results = {
            "count": subset.count(),
            "compositors": subset.map(lambda p: (get_compositor(p),)).countByKey(),
            # Setting to empty list due to histogram deprecation.
            # For more info see: https://bugzilla.mozilla.org/show_bug.cgi?id=1914369
            "plugin_models": [],
            "content_backends": get_content_backends(subset),
            "media_decoders": get_media_decoders(subset),
            "gpu_process": gpu_process_map(subset),
            "advanced_layers": advanced_layers_map(subset),
        }
        try:
            if int(os_version.split(".")[0]) >= 6:
                results["d3d11"] = subset.map(
                    lambda p: (get_d3d11_status(p),)
                ).countByKey()
                results["d2d"] = subset.map(get_d2d_status).countByKey()

                warp_pings = subset.filter(lambda p: get_d3d11_status(p) == "warp")
                results["warp"] = warp_pings.map(
                    lambda p: (get_warp_status(p),)
                ).countByKey()
        except Exception:
            pass
        finally:
            # Free resources.
            warp_pings = None
            subset = None
        windows_features_by_version[os_version] = results

    return {
        "all": {
            "compositors": windows_compositor_map,
            "content_backends": content_backends,
            "d3d11": d3d11_status_map,
            "d2d": d2d_status_map,
            "textureSharing": texture_sharing_map,
            "warp": warp_status_map,
            # Setting to empty list due to histogram deprecation.
            # For more info see: https://bugzilla.mozilla.org/show_bug.cgi?id=1914369
            "plugin_models": [],
            "media_decoders": media_decoders,
            "gpu_process": gpu_process_map(windows_features),
            "advanced_layers": advanced_layers_map(windows_features),
        },
        "byVersion": windows_features_by_version,
        "d3d11_blacklist": {
            "devices": blacklisted_devices,
            "drivers": blacklisted_drivers,
            "os": blacklisted_os,
        },
        "d3d11_blocked": {"vendors": blocked_vendors},
    }